export default {
  setUserInfo(state, userInfo) {
    state.userInfo = userInfo
    uni.setStorageSync('userInfo', userInfo)
  },
  setOpenId(state, openId) {
    state.openId = openId
    uni.setStorageSync('openId', openId)
  },
  setHistoryKeyWord(state, historyKeyWord) {
    const arr = state.historyKeyWord
    if (arr.length === 0) {
      arr.push(historyKeyWord)
    } else {
      const i = arr.indexOf(historyKeyWord)
      if (i !== -1) {
        arr.splice(i, 1)
        arr.push(historyKeyWord)
      } else {
        arr.push(historyKeyWord)
      }
    }
  },
  clearHistoryKeyWord(state) {
    state.historyKeyWord = []
  }
}
